extends Control

export (int) var vmargin = 48
var zone_rect : Rect2 setget set_rect

func resize_tm(tm : TileMap):
	var _R : Rect2
	_R = tm.get_used_rect()
	_R.size *= tm.cell_size
	set_rect(_R)

func set_rect(R: Rect2):
	var s = R.size
	R.size = Vector2(R.size.x, R.size.y / 2 - vmargin)
	R.position =  R.position + Vector2.DOWN * (s.y/2 + vmargin)
	$DeploymentZone.rect_size = R.size
	$DeploymentZone.rect_position = R.position
	$Line2D.points = [
		R.position,
		R.position + Vector2.RIGHT * R.size.x,
		R.position + R.size,
		R.position + Vector2.DOWN * R.size.y,
		R.position
	]
	zone_rect = R
